package com.deyuanyun.pic.ae.controller.vo;

import com.deyuanyun.pic.ae.domain.Sewer;
import com.deyuanyun.pic.ae.enumeration.YesOrNoEnum;
import com.deyuanyun.pic.ae.enumeration.PositionRelationEnum;
import com.deyuanyun.pic.common.util.NumberUtil;
import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.pipe.util.PipeMgrUtil;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.math.BigDecimal;

/**
 * E_4管道沿线地下排水排污设施信息表
 */
public class SewerVO extends AEBaseVO<Sewer> {
    // 管道id
    private String pipeLineName;
    // 名称
    private String name;
    // 类型AESEWER_TYPE（公路、铁路、高铁、地铁、高架、其它）
    private String type;
    // 所属单位
    private String owner;
    // 联系人/单位
    private String contact;
    // 联系方式
    private String telephone;
    // 相对位置关系（交叉、平行）CROSS、PARALLEL
    private String relativePositionRelation;
    // (填写)平行起点_附近测试桩pic_pipe_identification.ID_
    private String beginNagmInput;
    // (填写)平行起点_附近测试桩距离（相对值）
    private BigDecimal beginNagmMileageInput;
    // (填写)平行段终点_附近测试桩pic_pipe_identification.ID_
    private String endNagmInput;
    // (填写)平行段终点_附近测试桩距离（相对值）
    private BigDecimal endNagmMileageInput;
    // 最小平行间距（m）
    private BigDecimal minDistance;
    // (填写)交叉段_附近测试桩pic_pipe_identification.ID_
    private String crossNagmInput;
    // (填写)交叉段_附近测试桩距离（相对值）
    private BigDecimal crossNagmMileageInput;
    // 位置描述
    private String locationDescription;
    // 是否密闭空间（TES、NO）
    private String confinedSpace;

    // 数据状态
    private String dataStated;
    private String gisid;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getRelativePositionRelation() {
        return relativePositionRelation;
    }

    public void setRelativePositionRelation(String relativePositionRelation) {
        this.relativePositionRelation = relativePositionRelation;
    }

    public String getBeginNagmInput() {
        return beginNagmInput;
    }

    public void setBeginNagmInput(String beginNagmInput) {
        this.beginNagmInput = beginNagmInput;
    }

    public BigDecimal getBeginNagmMileageInput() {
        return beginNagmMileageInput;
    }

    public void setBeginNagmMileageInput(BigDecimal beginNagmMileageInput) {
        this.beginNagmMileageInput = beginNagmMileageInput;
    }

    public String getEndNagmInput() {
        return endNagmInput;
    }

    public void setEndNagmInput(String endNagmInput) {
        this.endNagmInput = endNagmInput;
    }

    public BigDecimal getEndNagmMileageInput() {
        return endNagmMileageInput;
    }

    public void setEndNagmMileageInput(BigDecimal endNagmMileageInput) {
        this.endNagmMileageInput = endNagmMileageInput;
    }

    public BigDecimal getMinDistance() {
        return minDistance;
    }

    public void setMinDistance(BigDecimal minDistance) {
        this.minDistance = minDistance;
    }

    public String getCrossNagmInput() {
        return crossNagmInput;
    }

    public void setCrossNagmInput(String crossNagmInput) {
        this.crossNagmInput = crossNagmInput;
    }

    public BigDecimal getCrossNagmMileageInput() {
        return crossNagmMileageInput;
    }

    public void setCrossNagmMileageInput(BigDecimal crossNagmMileageInput) {
        this.crossNagmMileageInput = crossNagmMileageInput;
    }

    public String getLocationDescription() {
        return locationDescription;
    }

    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription;
    }

    public String getConfinedSpace() {
        return confinedSpace;
    }

    public void setConfinedSpace(String confinedSpace) {
        this.confinedSpace = confinedSpace;
    }

    public String getDataStated() {
        return dataStated;
    }

    public void setDataStated(String dataStated) {
        this.dataStated = dataStated;
    }

    public String getGisid() {
        return gisid;
    }

    public void setGisid(String gisid) {
        this.gisid = gisid;
    }

    @Override
    public void fromDomain(Sewer domain) {

        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 名称
        this.name = domain.getName();
        // 类型AESEWER_TYPE（公路、铁路、高铁、地铁、高架、其它）
        this.type = CodeUtil.getName(domain.getType());
        // 所属单位
        this.owner = domain.getOwner();
        // 联系方式
        this.telephone = domain.getTelephone();
        // 相对位置关系（交叉、平行）CROSS、PARALLEL
        this.relativePositionRelation =  PositionRelationEnum.getLabel(domain.getRelativePositionRelation());

        if (PositionRelationEnum.PARALLEL.toString().equals(domain.getRelativePositionRelation())) {
            // (填写)平行起点_附近测试桩pic_pipe_identification.ID_
//        this.beginNagmInput = StringUtils.isNotNullEmpty(domain.getBeginNagmInput()) ? PipeMgrUtil.getIdentificationNumber(domain.getBeginNagmInput()) : PipeMgrUtil.getIdentificationNumber(domain.getBeginNagm());
            this.beginNagmInput = StringUtils.isNotNullEmpty(domain.getBeginNagmNumberInput()) ? domain.getBeginNagmNumberInput() : domain.getBeginNagmNumber();
            // (填写)平行起点_附近测试桩距离（相对值）
            Long beginNagmMileageTemp = StringUtils.isNotNullEmpty(domain.getBeginNagmNumberInput()) ?  domain.getBeginNagmMileageInput() : domain.getBeginNagmMileage();
            this.beginNagmMileageInput = NumberUtil.toMeter(beginNagmMileageTemp);
            // (填写)平行段终点_附近测试桩pic_pipe_identification.ID_
//        this.endNagmInput = StringUtils.isNotNullEmpty(domain.getEndNagmInput()) ? PipeMgrUtil.getIdentificationNumber(domain.getEndNagmInput()) : PipeMgrUtil.getIdentificationNumber(domain.getEndNagm());
            this.endNagmInput = StringUtils.isNotNullEmpty(domain.getEndNagmNumberInput()) ? domain.getEndNagmNumberInput() : domain.getEndNagmNumber();
            // (填写)平行段终点_附近测试桩距离（相对值）
            Long endNagmMileageTemp = StringUtils.isNotNullEmpty(domain.getEndNagmNumberInput()) ? domain.getEndNagmMileageInput() : domain.getEndNagmMileage();
            this.endNagmMileageInput = NumberUtil.toMeter(endNagmMileageTemp);
            // 最小平行间距（m）
            this.minDistance = domain.getMinDistance();
            // 位置描述
            this.locationDescription = domain.getLocationDescription();
            // 是否密闭空间（TES、NO）
            this.confinedSpace = YesOrNoEnum.getLabel(domain.getConfinedSpace());
        } else {
            // (填写)交叉段_附近测试桩pic_pipe_identification.ID_
//        this.crossNagmInput = StringUtils.isNotNullEmpty(domain.getCrossNagmInput()) ? PipeMgrUtil.getIdentificationNumber(domain.getCrossNagmInput()) : PipeMgrUtil.getIdentificationNumber(domain.getCrossNagm());
            this.crossNagmInput = StringUtils.isNotNullEmpty(domain.getCrossNagmInput()) ? domain.getCrossNagmNumberInput() : domain.getCrossNagmNumber();
            // (填写)交叉段_附近测试桩距离（相对值）
            Long crossNagmMileageTemp = StringUtils.isNotNullEmpty(domain.getCrossNagmInput()) ? domain.getCrossNagmMileageInput() : domain.getCrossNagmMileage();
            this.crossNagmMileageInput = NumberUtil.toMeter(crossNagmMileageTemp);;
        }

        // 数据状态
        this.dataStated = domain.getDataStated();
        this.gisid = domain.getGisid();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getRemarks());
    }

    public Page<SewerVO> fromDomainList(Page<Sewer> domainList) {
        Page<SewerVO> list = new Page<SewerVO>();
        for (Sewer sewer : domainList) {
            SewerVO sewerVO = new SewerVO();
            sewerVO.fromDomain(sewer);
            list.add(sewerVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}